package com.zztl.infiniteBand.base

import android.os.Bundle

import com.zztl.infiniteBand.ui.view.mvpview.MvpView


/**
 * @desc
 * @auth ${user}
 * @time 2018/6/11  13:45
 */
abstract class BaseMvpFragment<V: MvpView,P : BasePresenter<V>> : BaseFragment() {
     var presenter: P? = null

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        presenter = createPresenter()
        if (null != presenter) {
            presenter!!.attachView(this as V)
        }
    }


    protected abstract fun createPresenter(): P

    override fun onDestroy() {
        super.onDestroy()
        if (null != presenter) {
            presenter!!.detachView()
            presenter = null
        }
    }
}
